export default {
    /* 可以更改数组的属性名，第一个参数为要更改的数组，第二个参数为更换属性名的键值对[{key:'txt',value:'name'}] */
    copyTransFunc (obj, typeArr) {
        let result;
        let toString = Object.prototype.toString;
        if (toString.call (obj) === '[object Array]') {
            result = [];
            for (let i = 0; i < obj.length; i++) {
                result[i] = this.copyTransFunc (obj[i], arguments[1])
            }
        } else if (toString.call (obj) === '[object Object]') {
            result = {};
            for (let _key in obj) {
                if (obj.hasOwnProperty (_key)) {
                    let flag = 0, _value = null;
                    for (let j = 0; j < arguments[1].length; j++) {
                        if (arguments[1][j].key === _key) {
                            flag = 1;
                            _value = arguments[1][j].value
                        }
                    }
                    if (flag)
                        result[_value] = this.copyTransFunc (obj[_key], arguments[1]);
                    else
                        result[_key] = this.copyTransFunc (obj[_key], arguments[1])
                }
            }
        } else {
          return obj
        }
        return result
    }
}
